using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using Beetle.Controller;

internal class q
{
	private static string m_a = "abcdefghijklmnopqrstuvwxyz";

	private static Dictionary<string, Type> m_b = new Dictionary<string, Type>();

	private static Dictionary<string, XmlSerializer> m_c = new Dictionary<string, XmlSerializer>();

	private static object m_d = new object();

	public static int e = 524288;

	[ThreadStatic]
	private static char[] m_f;

	[CompilerGenerated]
	private static AsyncCallback m_g;

	public static long a(DirectoryInfo A_0)
	{
		long num = 0L;
		FileInfo[] files = A_0.GetFiles();
		FileInfo[] array = files;
		foreach (FileInfo fileInfo in array)
		{
			num += fileInfo.Length;
		}
		DirectoryInfo[] directories = A_0.GetDirectories();
		DirectoryInfo[] array2 = directories;
		foreach (DirectoryInfo a_ in array2)
		{
			num += a(a_);
		}
		return num;
	}

	public static string a(int A_0)
	{
		Random random = new Random(Environment.TickCount);
		string text = "";
		for (int num = 0; num < A_0; num++)
		{
			text += q.m_a.Substring(random.Next(25), 1);
		}
		return text;
	}

	public static bool a(Array A_0)
	{
		if (A_0 == null || A_0.Length == 0)
		{
			return true;
		}
		return false;
	}

	public static bool a(IList A_0)
	{
		if (A_0 == null || A_0.Count == 0)
		{
			return true;
		}
		return false;
	}

	public static bool a(IDictionary A_0)
	{
		if (A_0 == null || A_0.Count == 0)
		{
			return true;
		}
		return false;
	}

	public static bool m(string A_0)
	{
		return string.IsNullOrEmpty(A_0);
	}

	public static string a(Assembly A_0)
	{
		return Path.GetDirectoryName(A_0.Location) + "\\";
	}

	public static string l(string A_0)
	{
		if (A_0.Substring(A_0.Length - 1, 1) != "\\")
		{
			return A_0 + "\\";
		}
		return A_0;
	}

	public static bool b(DateTime A_0)
	{
		if (A_0 == DateTime.MinValue)
		{
			return true;
		}
		return false;
	}

	public static bool k(string A_0)
	{
		int result;
		return int.TryParse(A_0, out result);
	}

	public static bool e(object A_0)
	{
		return k(A_0.ToString());
	}

	public static bool j(string A_0)
	{
		return Regex.IsMatch(A_0, "^(\\d+|(\\d+\\.\\d+)+)$", RegexOptions.IgnoreCase);
	}

	public static bool d(object A_0)
	{
		return j(A_0.ToString());
	}

	public static bool i(string A_0)
	{
		DateTime result;
		return DateTime.TryParse(A_0, out result);
	}

	public static bool c(object A_0)
	{
		return i(A_0.ToString());
	}

	public static Type h(string A_0)
	{
		string[] array = A_0.Split(',');
		Assembly assembly = Assembly.Load(array[1]);
		return assembly.GetType(array[0], throwOnError: true);
	}

	public static Type g(string A_0)
	{
		if (!q.m_b.ContainsKey(A_0))
		{
			lock (q.m_b)
			{
				if (!q.m_b.ContainsKey(A_0))
				{
					Type type = Type.GetType(A_0);
					q.m_b.Add(A_0, type);
				}
			}
		}
		return q.m_b[A_0];
	}

	public static byte[] b(object A_0)
	{
		if (A_0 == null)
		{
			return null;
		}
		using MemoryStream memoryStream = new MemoryStream();
		BinaryFormatter binaryFormatter = new BinaryFormatter();
		binaryFormatter.Serialize(memoryStream, A_0);
		memoryStream.Position = 0L;
		byte[] array = new byte[memoryStream.Length];
		memoryStream.Read(array, 0, array.Length);
		memoryStream.Close();
		return array;
	}

	public static string a(object A_0)
	{
		byte[] inArray = b(A_0);
		return Convert.ToBase64String(inArray);
	}

	public static object c(byte[] A_0)
	{
		return a(A_0, A_0.Length);
	}

	public static object a(byte[] A_0, int A_1, int A_2)
	{
		object result = null;
		if (A_0 == null)
		{
			return result;
		}
		using MemoryStream memoryStream = new MemoryStream(A_0, A_1, A_2);
		memoryStream.Position = 0L;
		BinaryFormatter binaryFormatter = new BinaryFormatter();
		result = binaryFormatter.Deserialize(memoryStream);
		memoryStream.Close();
		return result;
	}

	public static object a(byte[] A_0, int A_1)
	{
		return a(A_0, 0, A_1);
	}

	public static object f(string A_0)
	{
		byte[] a_ = Convert.FromBase64String(A_0);
		return c(a_);
	}

	public static string a(DateTime A_0)
	{
		string text = "〇一二三四五六七八九";
		StringBuilder stringBuilder = new StringBuilder();
		string[] array = new string[3]
		{
			A_0.Year.ToString(),
			A_0.Month.ToString("00"),
			A_0.Day.ToString("00")
		};
		for (int num = 0; num < array[0].Length; num++)
		{
			int startIndex = int.Parse(array[0].Substring(num, 1));
			stringBuilder.Append(text.Substring(startIndex, 1));
		}
		stringBuilder.Append("年");
		for (int num2 = 0; num2 < array[1].Length; num2++)
		{
			int startIndex = int.Parse(array[1].Substring(num2, 1));
			if (num2 == 0)
			{
				if (startIndex > 0)
				{
					stringBuilder.Append("十");
				}
			}
			else if (startIndex > 0)
			{
				stringBuilder.Append(text.Substring(startIndex, 1));
			}
		}
		stringBuilder.Append("月");
		for (int num3 = 0; num3 < array[2].Length; num3++)
		{
			int startIndex = int.Parse(array[2].Substring(num3, 1));
			if (num3 == 0)
			{
				if (startIndex > 0)
				{
					if (startIndex > 1)
					{
						stringBuilder.Append(text.Substring(startIndex, 1));
					}
					stringBuilder.Append("十");
				}
			}
			else if (startIndex > 0)
			{
				stringBuilder.Append(text.Substring(startIndex, 1));
			}
		}
		stringBuilder.Append("日");
		return stringBuilder.ToString();
	}

	public static T[] ListToArray<T>(IList list)
	{
		T[] array = new T[list.Count];
		list.CopyTo(array, 0);
		return array;
	}

	public static int e(string A_0)
	{
		int num = 0;
		foreach (char a_ in A_0)
		{
			if (a(a_))
			{
				num++;
			}
		}
		if (num % 2 != 0)
		{
			num--;
		}
		return num / 2;
	}

	public static byte[] a(string A_0, out int A_1)
	{
		A_1 = 0;
		string text = "";
		foreach (char c2 in A_0)
		{
			if (a(c2))
			{
				text += c2;
			}
			else
			{
				A_1++;
			}
		}
		if (text.Length % 2 != 0)
		{
			A_1++;
			text = text.Substring(0, text.Length - 1);
		}
		int num2 = text.Length / 2;
		byte[] array = new byte[num2];
		int num3 = 0;
		for (int num4 = 0; num4 < array.Length; num4++)
		{
			string a_ = new string(new char[2]
			{
				text[num3],
				text[num3 + 1]
			});
			array[num4] = c(a_);
			num3 += 2;
		}
		return array;
	}

	public static string a(Encoding A_0, byte[] A_1, int A_2, int A_3)
	{
		return A_0.GetString(A_1, A_2, A_3);
	}

	public static string b(byte[] A_0)
	{
		string text = "";
		for (int num = 0; num < A_0.Length; num++)
		{
			text += A_0[num].ToString("X2");
		}
		return text;
	}

	public static bool d(string A_0)
	{
		bool result = true;
		foreach (char a_ in A_0)
		{
			if (!a(a_))
			{
				result = false;
				break;
			}
		}
		return result;
	}

	public static bool a(char A_0)
	{
		int num = Convert.ToInt32('A');
		int num2 = Convert.ToInt32('0');
		A_0 = char.ToUpper(A_0);
		int num3 = Convert.ToInt32(A_0);
		if (num3 >= num && num3 < num + 6)
		{
			return true;
		}
		if (num3 >= num2 && num3 < num2 + 10)
		{
			return true;
		}
		return false;
	}

	private static byte c(string A_0)
	{
		if (A_0.Length > 2 || A_0.Length <= 0)
		{
			throw new ArgumentException("hex must be 1 or 2 characters in length");
		}
		return byte.Parse(A_0, NumberStyles.HexNumber);
	}

	public static byte[] a(byte[] A_0)
	{
		MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider();
		return mD5CryptoServiceProvider.ComputeHash(A_0);
	}

	public static string b(string A_0)
	{
		byte[] bytes = Encoding.UTF8.GetBytes(A_0);
		bytes = a(bytes);
		return b(bytes);
	}

	public static T[] GetFieldAttributes<T>(FieldInfo field, bool inhert) where T : Attribute
	{
		return (T[])field.GetCustomAttributes(typeof(T), inhert);
	}

	public static T[] GetTypeAttributes<T>(Type type, bool inhert) where T : Attribute
	{
		return (T[])type.GetCustomAttributes(typeof(T), inhert);
	}

	public static T[] GetPropertyAttributes<T>(PropertyInfo pi, bool inhert) where T : Attribute
	{
		return (T[])pi.GetCustomAttributes(typeof(T), inhert);
	}

	public static T[] GetMethodAttributes<T>(MethodInfo mi, bool inhert) where T : Attribute
	{
		return (T[])mi.GetCustomAttributes(typeof(T), inhert);
	}

	public static T[] GetParemeterAttributes<T>(ParameterInfo pi, bool inhert) where T : Attribute
	{
		return (T[])pi.GetCustomAttributes(typeof(T), inhert);
	}

	public static void a(AsyncDelegate A_0)
	{
		A_0.BeginInvoke(delegate(IAsyncResult A_0)
		{
			GetEndHandler<AsyncDelegate>(A_0).EndInvoke(A_0);
		}, null);
	}

	public static void Action<T>(T t, AsyncDelegate<T> handler)
	{
		handler.BeginInvoke(t, delegate(IAsyncResult ac)
		{
			GetEndHandler<AsyncDelegate<T>>(ac).EndInvoke(ac);
		}, null);
	}

	public static void Action<T, T1>(T t, T1 t1, AsyncDelegate<T, T1> handler)
	{
		handler.BeginInvoke(t, t1, delegate(IAsyncResult ac)
		{
			GetEndHandler<AsyncDelegate<T, T1>>(ac).EndInvoke(ac);
		}, null);
	}

	public static void Action<T, T1, T2>(T t, T1 t1, T2 t2, AsyncDelegate<T, T1, T2> handler)
	{
		handler.BeginInvoke(t, t1, t2, delegate(IAsyncResult ac)
		{
			GetEndHandler<AsyncDelegate<T, T1, T2>>(ac).EndInvoke(ac);
		}, null);
	}

	public static void Action<T, T1, T2, T3>(T t, T1 t1, T2 t2, T3 t3, AsyncDelegate<T, T1, T2, T3> handler)
	{
		handler.BeginInvoke(t, t1, t2, t3, delegate(IAsyncResult ac)
		{
			GetEndHandler<AsyncDelegate<T, T1, T2, T3>>(ac).EndInvoke(ac);
		}, null);
	}

	public static void Action<T, T1, T2, T3, T4>(T t, T1 t1, T2 t2, T3 t3, T4 t4, AsyncDelegate<T, T1, T2, T3, T4> handler)
	{
		handler.BeginInvoke(t, t1, t2, t3, t4, delegate(IAsyncResult ac)
		{
			GetEndHandler<AsyncDelegate<T, T1, T2, T3, T4>>(ac).EndInvoke(ac);
		}, null);
	}

	private static T GetEndHandler<T>(IAsyncResult e)
	{
		return (T)((AsyncResult)e).AsyncDelegate;
	}

	public static XmlSerializer a(Type A_0, XmlRootAttribute A_1)
	{
		string key = A_0.FullName + ((A_1 != null) ? A_1.ElementName : "");
		if (!q.m_c.ContainsKey(key))
		{
			lock (q.m_d)
			{
				if (!q.m_c.ContainsKey(key))
				{
					if (A_1 != null)
					{
						q.m_c.Add(key, new XmlSerializer(A_0, A_1));
					}
					else
					{
						q.m_c.Add(key, new XmlSerializer(A_0));
					}
				}
			}
		}
		return q.m_c[key];
	}

	public void a(string A_0, string A_1, string A_2, string A_3, bool A_4, IEnumerable<string> A_5, IEnumerable<string> A_6)
	{
		MailMessage mailMessage = new MailMessage();
		mailMessage.From = new MailAddress(A_0);
		foreach (string item in A_5)
		{
			mailMessage.To.Add(item);
		}
		if (A_6 != null)
		{
			foreach (string item2 in A_6)
			{
				Attachment attachment = new Attachment(item2, "application/octet-stream");
				ContentDisposition contentDisposition = attachment.ContentDisposition;
				contentDisposition.CreationDate = File.GetCreationTime(item2);
				contentDisposition.ModificationDate = File.GetLastWriteTime(item2);
				contentDisposition.ReadDate = File.GetLastAccessTime(item2);
				mailMessage.Attachments.Add(attachment);
			}
		}
		mailMessage.Subject = A_2;
		mailMessage.Body = A_3;
		mailMessage.BodyEncoding = Encoding.UTF8;
		mailMessage.IsBodyHtml = A_4;
		mailMessage.Priority = MailPriority.Normal;
		SmtpClient smtpClient = new SmtpClient();
		smtpClient.Credentials = new NetworkCredential(mailMessage.From.Address, A_1);
		smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
		smtpClient.Host = "smtp." + mailMessage.From.Host;
		smtpClient.Send(mailMessage);
	}

	public static bool a(string A_0, out string A_1)
	{
		A_1 = ConfigurationManager.AppSettings[A_0];
		return !string.IsNullOrEmpty(A_1);
	}

	public static string a(string A_0)
	{
		return ConfigurationManager.AppSettings[A_0];
	}

	public static T AppSettingValue<T>(string name)
	{
		object obj = a(name);
		if (obj == null)
		{
			return default(T);
		}
		return (T)Convert.ChangeType(obj, typeof(T));
	}

	public static void Is<T>(object obj, AsyncDelegate<T> handler)
	{
		if (obj is T)
		{
			handler((T)obj);
		}
	}

	public static IEnumerable<T> Find<T>(IEnumerable source, EventFindHandler<T> handler)
	{
		List<T> list = new List<T>();
		if (source != null)
		{
			foreach (object item in source)
			{
				if (handler((T)item))
				{
					list.Add((T)item);
				}
			}
			return list;
		}
		return list;
	}

	[SpecialName]
	public static string b()
	{
		return Path.GetDirectoryName(typeof(q).Assembly.Location) + "\\";
	}

	public static char[] a()
	{
		if (q.m_f == null)
		{
			q.m_f = new char[q.e];
		}
		return q.m_f;
	}

	public static string a(string A_0, string A_1, string A_2)
	{
		char[] array = a();
		int num = 0;
		int num2 = 0;
		int length = A_0.Length;
		int length2 = A_1.Length;
		int length3 = A_2.Length;
		int num3 = 0;
		int num4 = 0;
		bool flag = false;
		while (num3 < A_0.Length)
		{
			flag = true;
			for (int num5 = 0; num5 < length2; num5++)
			{
				if (A_0[num3 + num5] != A_1[num5])
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				num4 = num3 - num2;
				A_0.CopyTo(num2, array, num, num4);
				num += num4;
				num3 += length2;
				num2 = num3;
				A_2.CopyTo(0, array, num, length3);
				num += length3;
			}
			else
			{
				num3++;
			}
		}
		if (num2 < length)
		{
			num4 = num3 - num2;
			A_0.CopyTo(num2, array, num, num4);
			num += num4;
		}
		return new string(array, 0, num);
	}

	[CompilerGenerated]
	private static void a(IAsyncResult A_0)
	{
		GetEndHandler<AsyncDelegate>(A_0).EndInvoke(A_0);
	}
}
